package com.zxr.web.controller.wx;

import com.zxr.common.core.controller.BaseController;
import com.zxr.common.core.domain.AjaxResult;
import com.zxr.common.utils.OrderUtils;
import com.zxr.system.domain.OrderItems;
import com.zxr.system.domain.Products;
import com.zxr.system.service.IOrderItemsService;
import com.zxr.system.service.IProductsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wx/order")
public class WxOrderContoller extends BaseController {

    @Autowired
    private IOrderItemsService orderItemsService;
    @Autowired
    private IProductsService productsService;

    /**
     * 新增保存订单商品明细
     */
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(OrderItems orderItems)
    {
        String orderNo = OrderUtils.generateOrderNumber();
        Long memberId = orderItems.getMemberId();
        //查询商品
        Products products = productsService.selectProductsByProductId(orderItems.getProductId());
        return toAjax(orderItemsService.insertOrderItems(orderItems));
    }


}
